<%-- 
    Document   : goaddclass
    Created on : 2013-5-8, 14:39:29
    Author     : Sam.Zheng <zcl1866@sina.com>
--%>
<%String Path = request.getContextPath();%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <c:import url="/resource/include/header.jsp" />
        <title>新建班级</title>
        <style>
            tr td{
                border:  1px solid ;
            }
        </style>
        <script>
            
            function doSubmit(){
                if($("#className").val()==""){
                    win.alert("提示", "名称不能为空");
                    return ;
                }
                $("#frm").submit();
            }
            
            function doDelClass(){
             var id  = "";
             var chk = $(":checkbox:checked");
             if(chk.length>1){
                  win.alert("提示","一次只能删除一条！");return;
             }
             id = $(":checkbox:checked")[0].value;
             if(id == ""){
                 win.alert("提示","请先选择要删除的项！");
                 return;
             }
               $.ajax({
                   type:"get",
                   url :"<%=Path%>/app/index/delclass/"+id,
                   contentType:"text/html;charset=utf-8",
                   success: function (msg){
                       if(msg == 1){
                           win.messageBox("提示", "删除成功！",function(){location.href="<%=Path%>/app/index/goAddClass"});
                       }else if(msg==0){
                            win.messageBox("提示", "删除失败");
                       }else{
                            win.messageBox("错误", msg);
                       }
                   },
                   error: function(msg){
                        alert("删除失败！");
                   }
                   
               });
            }
            function doFindClass(){
                if($("#className").val()==""){
                    win.alert("提示", "查询名称不能为空");
                    return ;
                }
                $("#frm").submit();
            }
        </script>
            
    </head>
    <body>
        <form id="frm" method="post" action="<%=Path%>/app/index/addclass" target="_self">
            <div style="text-align: center;margin: 100px 0px 0 400px">
                
                <table >
                    <tr >
                        <td colspan="3" >
                            班级名称 :<input class="easyui-validatebox" type="text" id="className" name="className" data-options="required:true"></input>
                            <a href="javascript:doSubmit()">添加</a> | <a href="javascript:doDelClass()">删除</a>
                        </td>
                    </tr>
                    <tr>
                        <td>序号</td> <td>编号</td><td>班级名称</td>
                    </tr>
                    <c:forEach items="${list}" var="cla" varStatus="i" >
                    <tr>
                        <td><input type="checkbox" name="id" value="${cla.id}"/>${i.index + 1}</td>
                        <td>${cla.id}</td>
                        <td>${cla.className}</td>
                    </tr>
                    </c:forEach>
                    
                </table>
                
            </div>
        </form>
    </body>
</html>
